package com.smartmedical.patient.share.controller;

import com.smartmedical.common.core.domain.HealthR;
import com.smartmedical.patient.share.domain.*;
import com.smartmedical.patient.share.service.KnowledgeBaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static com.smartmedical.common.core.utils.PageUtils.startPage;

@RestController
@RequestMapping("share/knowledgeBase/v1")
public class KnowledgeBaseController {
    @Autowired
    private KnowledgeBaseService knowledgeBaseService;

    /**
     * 查询科室列表
     *
     */
    @GetMapping("/findDepartment")
    public HealthR<List<Department>> findDepartment() {
        return knowledgeBaseService.findDepartment();
    }
    /**
     * 常见病症展示（根据科室分类）
     * departmentId 科室id
     */
    @GetMapping("/findDiseaseCategory")
    public HealthR<List<DiseaseCategory>> DiseaseSearch(@RequestParam("departmentId") int departmentId) {
        return knowledgeBaseService.DiseaseSearch(departmentId);
    }
    /**
     * 根据常见病症查询具体病症详情
     */
    @GetMapping("findDiseaseKnowledge")
    public HealthR<DiseaseKnowledge> findDiseaseKnowledge(@RequestParam("id") int id) {
        return knowledgeBaseService.findDiseaseKnowledge(id);
    }
    /**
     * 药品科目分类列表查询
     */
    @GetMapping("findDrugsCategoryList")
    public HealthR<List<DrugsCategory>> findDrugsCategoryList() {
        return knowledgeBaseService.findDrugsCategoryList();
    }
    /**
     * 根据药品类目查询常见药品
     * @RequestParam入参
     * drugsCategoryId 药品类目id
     * page 页码
     * count 页大小
     */
    @GetMapping("findDrugsKnowledgeList")
    public HealthR<List<DrugsKnowledge>> findDrugsKnowledgeList(@RequestParam( value = "drugsCategoryId",defaultValue = "1") int drugsCategoryId,
                                                                @RequestParam(value = "page",defaultValue = "1") int page,
                                                                @RequestParam(value = "count",defaultValue = "2") int count) {
        startPage(page,count);
        return knowledgeBaseService.findDrugsKnowledgeList(drugsCategoryId);
    }
    /**
     * 查询常见药品详情
     * @RequestParam入参
     * id 药品id
     */
    @GetMapping("findDrugsKnowledge")
    public HealthR<DrugsKnowledge> findDrugsKnowledge(@RequestParam("id") int id) {
        return knowledgeBaseService.findDrugsKnowledge(id);
    }


}
